/*
 * @Author: wangyongcun
 * @Date: 2021-08-14 18:07:39
 * @LastEditors: wangyongcun
 * @LastEditTime: 2021-08-14 18:50:42
 * @Description: 处理vuex
 */
import { createStore } from 'vuex'
import state from '../store/state'
import mutations from '../store/mutations'
import actions from '../store/actions'
import getters from '../store/getters'

const paths = import.meta.globEager('../store/modules/*.ts');

const modules = Object.keys(paths).reduce((all, path: any) => {
    const key = path.match(/modules\/(\S*).ts/)[1];
    all[key] = paths[path].default;
    return all;
}, {});

const store = createStore({
    state, mutations, actions, getters, modules
})

export default store